﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Clearance_Action_Form.aspx.cs"
    EnableEventValidation="true" EnableViewState="true" Inherits="Trig_AMJ_HR_Forms.Layouts.Trig_AMJ_HR_Forms.Clearance_Action_Form"
    DynamicMasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="trig" TagName="ClearComments" Src="~/_controltemplates/Trig_AMJ_AMG_Forms/TrigAMJFormsComments/TrigAMJFormsCommentsUserControl.ascx" %>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <link rel="Stylesheet" type="text/css" href="/_layouts/1033/STYLES/Themable/FORMS.CSS" />
    <link rel="Stylesheet" type="text/css" href="/Style Library/Al Majed/CSS/Trig_HR.css" />
    <script language="javascript" type="text/javascript" src="/_layouts/Scripts/validation.js"></script>
    <style type="text/css">
        .ms-validations
        {
            color: Red;
        }
        
        #s4-leftpanel
        {
            display: none;
        }
        .s4-ca
        {
            margin-left: 0px;
        }
        .ms-validations
        {
            color: Red;
        }
        .style2
        {
            width: 373px;
        }
        .style3
        {
            width: 366px;
        }
        body, td, th
        {
            font-size: 8pt;
            font-family: Verdana, Arial, sans-serif;
        }
    </style>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <asp:Panel ID="pnlFullForm" runat="server" CssClass="pnlAMFform">
        <table cellpadding="0" cellspacing="0" class="tbl-main" width="1000px">
            <tr>
                <td colspan="4" class="formtitle">
                    FINANCIAL ACCOUNTABILITY CLEARANCE FORM
                </td>
            </tr>
            <tr>
                <td width="250px">
                    Reference No :
                </td>
                <td width="250px">
                    <asp:Label ID="lblClrReqNo" runat="server" Text="Reference number will be generated upon save"
                        Font-Bold="True" Font-Size="XX-Small" CssClass="ms-long ms-spellcheck-true" ForeColor="Red"></asp:Label>
                </td>
                <td align="right" width="250px">
                    Date of filling :
                </td>
                <td width="250px">
                    <SharePoint:DateTimeControl ID="dtReqDate" runat="server" DateOnly="true" IsRequiredField="true"
                        LocaleId="2057" Enabled="false" ErrorMessage="Please specify the date" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    TO WHOM IT MAY CONCERN:
                </td>
            </tr>
            <%--<tr>
                <td colspan="4" class="Note-td">
                    <asp:Label ID="lblInstruct" runat="server" Text="This is to certify that the requester of has been cleared from all his accountabilities
                    in connection with his/her application for:" CssClass="Notes-msg"></asp:Label>
                </td>
            </tr>--%>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Clearance Type
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:HiddenField runat="server" ID="hdnClearCK" />
                    <asp:RadioButtonList runat="server" ID="rdClearanceType" RepeatDirection="Horizontal"
                        AutoPostBack="true" OnSelectedIndexChanged="rdClearanceType_SelectedIndexChanged"
                        OnClick="javascript:EnableLeaves();">
                        <asp:ListItem Text="Vacation / (Annual)(Emergency)" Value="0" Selected="True"></asp:ListItem>
                        <asp:ListItem Text="Resignation" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Termination" Value="2"></asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td class="tdHeadingTextLeftAlign" colspan="4">
                    Requested Employee Information
                </td>
            </tr>
            <tr>
                <td width="250px">
                    Name :<span title="This is a required field." class="ms-validations"><strong>*</strong></span>
                </td>
                <td>
                    <SharePoint:PeopleEditor ID="pplReqUser" runat="server" MultiSelect="false" AutoPostBack="true"
                        SelectionSet="User" Width="250px" />
                    <asp:TextBox ID="txtReqUser" runat="server" ReadOnly="true" Width="250px" Visible="false"
                        Enabled="false"></asp:TextBox>
                </td>
                <td width="250px">
                    Employee ID :
                </td>
                <td>
                    <asp:TextBox ID="txtReqEmpId" runat="server" ReadOnly="true" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td width="250px">
                    Division :
                </td>
                <td>
                    <asp:TextBox ID="txtReqDivision" runat="server" Width="250px" ReadOnly="true"></asp:TextBox>
                </td>
                <td width="250px">
                    Department :
                </td>
                <td>
                    <asp:TextBox ID="txtReqDepartment" runat="server" Width="250px" ReadOnly="true"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td width="250px">
                    Designation :
                </td>
                <td>
                    <asp:TextBox ID="txtReqDesignation" runat="server" ReadOnly="true" Width="250px"></asp:TextBox>
                </td>
            </tr>
            <tr id="trLeaves" runat="server">
                <td width="250px">
                    Leave Reference No :
                </td>
                <td>
                    <asp:TextBox ID="txtLeaveRefNo" runat="server" Width="250px" ReadOnly="true"></asp:TextBox>
                </td>
                <td width="250px">
                    Leave Request Date :
                </td>
                <td width="250px">
                    <SharePoint:DateTimeControl ID="dtLeaveReqDate" runat="server" DateOnly="true" LocaleId="2057"
                        Enabled="false" />
                </td>
            </tr>
            <tr id="trLeaves1" runat="server">
                <td width="250px">
                    Leave Start Date :
                </td>
                <td width="250px">
                    <SharePoint:DateTimeControl ID="dtLeaveStartDT" runat="server" DateOnly="true" LocaleId="2057"
                        Enabled="false" />
                </td>
                <td width="250px">
                    Leave End Date :
                </td>
                <td width="250px">
                    <SharePoint:DateTimeControl ID="dtLeaveEndDT" runat="server" DateOnly="true" LocaleId="2057"
                        Enabled="false" />
                </td>
            </tr>
            <tr>
                <td width="250px">
                    Effective on : <span class="ms-validations" title="This is a required field."><strong>
                        *</strong></span>
                </td>
                <td colspan="3">
                    <SharePoint:DateTimeControl ID="dtEffectiveon" runat="server" DateOnly="true" LocaleId="2057" />
                </td>
            </tr>
            <asp:Panel runat="server" ID="pnlAccMain">
                <tr>
                    <td class="tdHeadingTextLeftAlign" colspan="4">
                        FINANCIAL ACCOUNTABILITIES
                    </td>
                </tr>
                <tr>
                    <asp:HiddenField runat="server" ID="hdnWF_Order" Value="0" />
                    <td colspan="4">
                        <asp:GridView ID="gvAccountablity" runat="server" AutoGenerateColumns="false" CssClass="Grid-default"
                            OnRowDataBound="gvAccountablity_RowDataBound" AlternatingRowStyle-CssClass="alt-tr"
                            ShowFooter="True">
                            <Columns>
                                <asp:TemplateField HeaderText="S.No" ItemStyle-CssClass="td-center" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtSNo" Text='<%# Container.DataItemIndex+1 %>' ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Division" ItemStyle-CssClass="td-left" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtGDivision" Text='<%# Eval("Division") %>' ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Accountants" ItemStyle-CssClass="td-left" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtGAccountant" Text='<%# Eval("Accountant") %>' ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Other Receivables" ItemStyle-CssClass="td-left" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtOtherReceivables" Text='<%# Eval("OtherReceivables") %>'
                                            ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Item Purchased" ItemStyle-CssClass="td-left" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtItemsPurchased" Text='<%# Eval("ItemsPurchased") %>'
                                            ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label ID="lblText" runat="server" Visible="true" Text="Total"></asp:Label>
                                    </FooterTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Cash Advance" ItemStyle-CssClass="td-right" HeaderStyle-CssClass="td-center">
                                    <ItemTemplate>
                                        <asp:Label runat="server" ID="txtAccountability" Text='<%# Eval("CashAdvance") %>'
                                            ReadOnly="true"></asp:Label>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label ID="lblTotal" runat="server" Visible="true"></asp:Label>
                                    </FooterTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <asp:Label runat="server" ID="lblGVAcc" Visible="false" Text="No Records found" CssClass="error-msg"></asp:Label>
                    </td>
                </tr>
            </asp:Panel>
            <asp:Panel runat="server" ID="pnlAccountablity">
                <tr>
                    <td colspan="1">
                        <strong>Accountablity</strong><span class="ms-validations" title="This is a required field."><strong>
                            *</strong></span>
                    </td>
                    <td colspan="3" align="left">
                        <asp:RadioButtonList runat="server" ID="rdAccountablity" RepeatDirection="Horizontal"
                            OnSelectedIndexChanged="rdAccountablity_SelectedIndexChanged" OnClick="javascript:EnableAccountablity();">
                            <asp:ListItem Text="Yes" Value="0" Selected="True"></asp:ListItem>
                            <asp:ListItem Text="No" Value="1"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr id="trAcc1">
                    <td class="tdCell">
                        Cash Advance : <span class="ms-validations" title="This is a required field."><strong>
                            *</strong></span>
                    </td>
                    <td class="tdCell">
                        <asp:TextBox runat="server" ID="txtCashAdv" Width="250px" onkeypress="return isNumberKey(this)"></asp:TextBox>
                    </td>
                    <td class="tdCell">
                        Other Receivables :
                    </td>
                    <td class="tdCell">
                        <asp:TextBox runat="server" ID="txtOtherRec" Width="250px"></asp:TextBox>
                    </td>
                </tr>
                <tr id="trAcc2">
                    <td class="tdCell">
                        Items Purchased : <span class="ms-validations" title="This is a required field."><strong>
                            *</strong></span>
                    </td>
                    <td class="tdCell" colspan="3">
                        <asp:TextBox runat="server" ID="txtItemPur" Width="250px"></asp:TextBox>
                    </td>
                </tr>
            </asp:Panel>
            <asp:Panel runat="server" ID="pnlOSView" Visible="false">
                <tr>
                    <td class="tdHeadingTextLeftAlign" colspan="4">
                        <strong>Outstanding Settlement</strong><span class="ms-validations" title="This is a required field."><strong>
                            *</strong></span>
                    </td>
                </tr>
                <tr>
                    <td>
                        Settlement Through
                    </td>
                    <td>
                        <asp:TextBox runat="server" ID="txtSettlement" ReadOnly="true" Width="250px"></asp:TextBox>
                    </td>
                    <td>
                        <SharePoint:PeopleEditor ID="pplGuarntor" runat="server" MultiSelect="false" AutoPostBack="true"
                            SelectionSet="User" Width="250px" Visible="false" Enabled="false" />
                    </td>
                </tr>
            </asp:Panel>
            <tr>
                <td colspan="4" class="tdHeadingTextLeftAlign">
                    Comments / Workflow Area
                </td>
            </tr>
            <tr>
                <td colspan="4" style="padding: 10px;">
                    <trig:ClearComments ID="ClrComments" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <table width="100%" cellpadding="0" cellspacing="0" class="Section-Approver">
                        <asp:Panel ID="pnlCommentArea" runat="server" class="Section-Approver">
                            <tr>
                                <td colspan="4" class="AppHeading">
                                    <strong>Comments</strong><span class="ms-validations" title="This is a required field."><strong>
                                        *</strong></span>
                                </td>
                            </tr>
                            <asp:Panel ID="plnSettle" runat="server" class="Section-Approver" Visible="false">
                                <tr>
                                    <td>
                                        Settlement Through
                                    </td>
                                    <td colspan="2" align="left">
                                        <asp:RadioButtonList runat="server" ID="rdOS" RepeatDirection="Horizontal" OnClick="javascript:EnableOS();">
                                            <asp:ListItem Text="Immediate" Value="0" Selected="True"></asp:ListItem>
                                            <asp:ListItem Text="Guarantor" Value="1"></asp:ListItem>
                                        </asp:RadioButtonList>
                                    </td>
                                    <td runat="server" id="tdGuarntor">
                                        <span class="ms-validations" title="This is a required field."><strong>*</strong></span>
                                        <SharePoint:PeopleEditor runat="server" ID="pplGuarantors" MultiSelect="false" SelectionSet="User"
                                             EnableViewState="true" />
                                    </td>
                                </tr>
                            </asp:Panel>
                            <tr>
                                <td class="tdCell">
                                    <asp:Image ID="ImgUser" runat="server" Height="50px" Width="50px" />
                                    <br />
                                    <asp:Label ID="LblCommentsUserName" runat="server" Font-Bold="True" Font-Size="XX-Small"
                                        ForeColor="#003399" Text=""></asp:Label>
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:TextBox ID="TxtComments" runat="server" TextMode="MultiLine" Width="600px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr id="upAtt" runat="server">
                                <td class="tdCell">
                                    Upload Attachment
                                </td>
                                <td colspan="3" class="tdCell">
                                    <asp:FileUpload ID="upfile" runat="server" CssClass="ms-fileinput" Width="250px" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel ID="pnlForward" runat="server" Visible="false">
                            <tr>
                                <td colspan="4" style="text-align: left; background-color: #121e66; color: #ffffff;
                                    font-weight: bold; padding: 10px;">
                                    <table cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbSendBack" runat="server" Text="Send Back" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnSendBackUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbSendBack" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForwardOthers" runat="server" Text="Forward to other user"
                                                            AutoPostBack="true" GroupName="Users" onclick="javascript:fnForwardUsers(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForwardOthers" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                            <td>
                                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                                    <ContentTemplate>
                                                        <asp:RadioButton ID="rtbForward" runat="server" Text="Forward" GroupName="Users"
                                                            AutoPostBack="true" onclick="javascript:fnForword(this)" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:AsyncPostBackTrigger ControlID="rtbForward" EventName="CheckedChanged" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="3">
                                                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                                    <ContentTemplate>
                                                        <asp:Label ID="lblWFStaticUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                        <asp:Label ID="lblSendBacktoUser" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow" Visible="false"></asp:Label>
                                                        <asp:Label ID="lblsendBackUserValue" runat="server" Text="" Font-Bold="True" Font-Size="XX-Small"
                                                            ForeColor="Yellow"></asp:Label>
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr style="padding: 10px; display: none" id="trotherUsers">
                                <td style="padding: 10px; font-weight: bold; color: #121e66;" width="130px">
                                    User Name :
                                </td>
                                <td style="padding: 10px;" colspan="3">
                                    <asp:Label ID="lblCNTSectionMsg" runat="server" Text=""></asp:Label>
                                    <SharePoint:PeopleEditor ID="pplcnt" runat="server" MultiSelect="false" AllowEmpty="false"
                                        Width="250px" ForeColor="Red" AutoPostBack="false" />
                                </td>
                            </tr>
                        </asp:Panel>
                        <asp:Panel runat="server" ID="btnCntrls">
                            <tr>
                                <td colspan="4">
                                    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                        <ContentTemplate>
                                            <asp:Label ID="lblError" runat="server" CssClass="error-msg" Text=""></asp:Label>
                                            <asp:Label ID="lblErrors" runat="server" CssClass="error-msg" Text="" Visible="false"></asp:Label>
                                        </ContentTemplate>
                                    </asp:UpdatePanel>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" class="tblButtons" style="padding-top: 5px;">
                                    <asp:HiddenField runat="server" ID="ckSubmit" Value="false" />
                                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="btn-Submit" OnClick="btnSubmit_Click"
                                        OnClientClick="javascript:return fnValidation();" />
                                    <asp:Button ID="btnApprove" runat="server" Text="Clearance Form Approval in Progress"
                                        CssClass="btn-Approver" OnClick="btnApprove_Click" OnClientClick="javascript:return fnAppValidation();"
                                        Visible="false" />
                                    <asp:Button ID="btnReject" runat="server" CssClass="btn-Reject" Text="Clearance Form Rejection in Progress"
                                        Visible="false" OnClientClick="javascript:return fnAppValidation();" />
                                    <input id="btnCancel" class="btn-Cancel" type="button" value="Close" accesskey="C"
                                        onclick="window.parent.history.back()" runat="server" />
                                </td>
                            </tr>
                        </asp:Panel>
                    </table>
                </td>
            </tr>
            <asp:Panel ID="pnlView" runat="server" Visible="false">
                <tr>
                    <td colspan="4" style="text-align: center;">
                        <input id="btnViewClose" class="btn-Cancel" type="button" onclick="window.parent.history.back()"
                            value="Close" accesskey="C" />
                    </td>
                </tr>
            </asp:Panel>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAccessDenied" runat="server" Visible="false" CssClass="pnlAMFform">
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td style="text-align: center;">
                    <asp:Label ID="lblAccessDeniedMsg" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                    <asp:Label ID="lblUserNotvailable" runat="server" Text="" Font-Size="Medium" ForeColor="Red"
                        Font-Bold="True" Visible="false"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px;">
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/_layouts/1033/IMAGES/IRForm/AccessDeniedImage.png" />
                </td>
            </tr>
            <tr>
                <td style="text-align: center; padding-top: 10px">
                    <input id="butonclose" class="btn-Cancel" type="button" onclick="SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, 'Cancel clicked'); return false;"
                        value="Close" accesskey="C" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAlert" runat="server">
    </asp:Panel>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= pplGuarantors.ClientID  %>').style.display = "none";

        function fnForwardUsers(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "inline";
            else
                document.getElementById("trotherUsers").style.display = "none";

        }

        function fnSendBackUsers(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "none";
        }
        function fnForword(obj) {
            if (obj.checked == true)
                document.getElementById("trotherUsers").style.display = "none";
        }

        function isNumberKey(evt) {
            if (charCode != 46 && charCode > 31
            && (charCode < 48 || charCode > 57))
                if (charCode > 31 && (charCode < 48 || charCode > 57))
                    return false;
            return true;
        }

        function EnableLeaves() {
            debugger;
            document.getElementById('<%= pplReqUser.ClientID %>').value = "";
        }


        function EnableAccountablity() {
            var MyRadio = document.getElementById("<%=rdAccountablity.ClientID%>");
            var options = MyRadio.getElementsByTagName("input");
            var radVal;
            for (x = 0; x < options.length; ++x) {
                if (options[x].checked) {
                    radVal = x;
                }
            }
            if (radVal == 0) {
                document.getElementById("trAcc1").style.display = "block";
                document.getElementById("trAcc2").style.display = "block";
            }
            else {
                document.getElementById("trAcc1").style.display = "none";
                document.getElementById("trAcc2").style.display = "none";
            }
        }


        function EnableOS() {
            debugger;
            var MyRadio = document.getElementById("<%=rdOS.ClientID%>");
            var options = MyRadio.getElementsByTagName("input");
            var radVal;
            for (x = 0; x < options.length; ++x) {
                if (options[x].checked) {
                    radVal = x;
                }
            }
            if (radVal == 0) {
                document.getElementById('<%= pplGuarantors.ClientID  %>').style.display = "none";

            }
            else {

                document.getElementById('<%= pplGuarantors.ClientID  %>').style.display = "block";
            }
        }




    </script>
    <script language="javascript" type="text/javascript">

        document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
        document.getElementById('<%= lblError.ClientID  %>').style.display = "none";

        function Trim(TrimString) {
            var tempObj;
            if (TrimString) { tempObj = TrimString; TrimString = tempObj.value; }
            if (TrimString == "undefined" || TrimString == null) return null;
            if (TrimString.length == 0) TrimString = "";
            else {
                var Lcont = 0, TempStrArray = TrimString.split(" "), Rcont = TempStrArray.length - 1;
                while (TempStrArray[Lcont] == "") Lcont++; while (TempStrArray[Rcont] == "") Rcont--;
                if (Rcont < Lcont) TrimString = ""; else
                    for (TrimString = TempStrArray[Lcont], Lcont++; Lcont <= Rcont; Lcont++) TrimString += " " + TempStrArray[Lcont];
                var re = /\'|/g;
                TrimString = TrimString.replace(re, "");
            }
            if (tempObj && TrimString != "undefined" && TrimString != null)
            { tempObj.value = TrimString; return tempObj }
            else return TrimString;
        }

        function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.search);
            if (results == null)
                return "";
            else
                return decodeURIComponent(results[1].replace(/\+/g, " "));
        }


        function ckOSPeople() {
            debugger;
            var MyRadio = document.getElementById("<%=rdOS.ClientID%>");
            var options = MyRadio.getElementsByTagName("input");
            var radVal;
            for (x = 0; x < options.length; ++x) {
                if (options[x].checked) {
                    radVal = x;
                }
            }
            if (radVal == 0) {
                document.getElementById('<%= pplGuarantors.ClientID  %>').style.display = "none";

            }
            else {

                document.getElementById('<%= pplGuarantors.ClientID  %>').style.display = "block";
            }
        }


        function isEmpties(obj) {
            var obj = document.getElementById("<%=rdOS.ClientID%>");
            if (typeof obj == 'undefined' || obj === null || obj === '' || obj.value == "") return true;
            if (typeof obj == 'number' && isNaN(obj)) return true;
            if (obj instanceof Date && isNaN(Number(obj))) return true;
            return false;
        }


        function fnAppValidation() {
            debugger;
            var querystringval = getParameterByName('Mode');
            document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
            var rval = true;
            var ErrorMsg = "";
            var objFocus;

            Trim(document.getElementById('<%= TxtComments.ClientID  %>'));
            Trim(document.getElementById('<%= pplGuarantors.ClientID  %>'));

            if (isEmpties()) {
                if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                    rval = false;
                }
            }
            else {
                var MyRadio = document.getElementById("<%=rdOS.ClientID%>");
                var options = MyRadio.getElementsByTagName("input");
                var radVal;
                for (x = 0; x < options.length; ++x) {
                    if (options[x].checked) {
                        radVal = x;
                    }
                }
                if (radVal == 0) {
                    if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }
                }
                else {
                    if (document.getElementById('<%= pplGuarantors.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= pplGuarantors.ClientID  %>');
                        rval = false;
                    }
                    else if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }
                }
            }


            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }

            else {
                document.getElementById('<%= ckSubmit.ClientID  %>').value = "True";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
                document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
            }

            return rval;

        }


        function fnValidation() {
            debugger;
            var querystringval = getParameterByName('Mode');
            document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
            var rval = true;
            var ErrorMsg = "";
            var objFocus;

            Trim(document.getElementById('<%= TxtComments.ClientID  %>'));
            Trim(document.getElementById('<%= pplReqUser.ClientID  %>'));
            Trim(document.getElementById('<%= dtReqDate.ClientID  %>'));
            Trim(document.getElementById('<%= dtEffectiveon.ClientID  %>'));
            Trim(document.getElementById('<%= dtLeaveStartDT.ClientID  %>'));
            Trim(document.getElementById('<%= dtLeaveEndDT.ClientID  %>'));

            Trim(document.getElementById('<%= txtCashAdv.ClientID  %>'));
            Trim(document.getElementById('<%= txtOtherRec.ClientID  %>'));
            Trim(document.getElementById('<%= txtItemPur.ClientID  %>'));

            Trim(document.getElementById('<%= ckSubmit.ClientID  %>'));

            var reqDt = document.getElementById('<%= dtReqDate.Controls[0].ClientID %>');
            var effectOn = document.getElementById('<%= dtEffectiveon.Controls[0].ClientID %>');

            var stDt = document.getElementById('<%= dtLeaveStartDT.Controls[0].ClientID %>');
            var endDt = document.getElementById('<%= dtLeaveEndDT.Controls[0].ClientID %>');

            if (querystringval == "New") {


                var MyRadio = document.getElementById("<%=rdClearanceType.ClientID%>");
                var options = MyRadio.getElementsByTagName("input");
                var radVal;
                for (x = 0; x < options.length; ++x) {
                    if (options[x].checked) {
                        radVal = x;
                    }
                }

                if (document.getElementById('<%= pplReqUser.ClientID  %>').value == "") {
                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                    objFocus = document.getElementById('<%= pplReqUser.ClientID  %>');
                    rval = false;
                }

                else if (radVal == 0) {

                    if (isEmpty(effectOn)) {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = effectOn;
                        rval = false;
                    }
                    else if (!IsValidDateFormat(effectOn.value)) {
                        ErrorMsg = "Date format should be dd/mm/yyyy !";
                        objFocus = effectOn;
                        rval = false;
                    }
                    else {
                        if (!PreSaveAction(reqDt, effectOn)) {
                            ErrorMsg = "The Effective on Date should be greater than Today";
                            objFocus = effectOn;
                            rval = false;
                        }
                        else {
                            if (!PreSaveAction(effectOn, endDt)) {
                                ErrorMsg = "The Effective on Date should be less than Return Date";
                                objFocus = effectOn;
                                rval = false;
                            }
                            else {
                                if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                                    ErrorMsg = "Fields marked with (*) cannot be left blank";
                                    objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                                    rval = false;
                                }
                            }
                        }
                    }

                }
                else {
                    if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }
                }
            }

            else {

                var MyRadio = document.getElementById("<%=rdAccountablity.ClientID%>");
                var options = MyRadio.getElementsByTagName("input");
                var radVal;
                for (x = 0; x < options.length; ++x) {
                    if (options[x].checked) {
                        radVal = x;
                    }
                }
                if (radVal == 0) {
                    if (document.getElementById('<%= txtCashAdv.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= txtCashAdv.ClientID  %>');
                        rval = false;
                    }

                    else if (document.getElementById('<%= txtItemPur.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= txtItemPur.ClientID  %>');
                        rval = false;
                    }
                    else if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }
                }
                else {

                    if (document.getElementById('<%= TxtComments.ClientID  %>').value == "") {
                        ErrorMsg = "Fields marked with (*) cannot be left blank";
                        objFocus = document.getElementById('<%= TxtComments.ClientID  %>');
                        rval = false;
                    }

                }

            }

            if (rval == false) {
                document.getElementById('<%= lblError.ClientID  %>').style.display = "block";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = ErrorMsg;
                objFocus.focus();
            }

            else {
                document.getElementById('<%= ckSubmit.ClientID  %>').value = "True";
                document.getElementById('<%= lblError.ClientID  %>').innerHTML = "";
                document.getElementById('<%= lblError.ClientID  %>').style.display = "none";
            }

            return rval;
        }





    </script>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Clearance Action Form
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
    runat="server">
    Clearance Action Form
</asp:Content>
